package com.wlgc.controller;

import com.wlgc.context.BaseContext;
import com.wlgc.entity.PageResult;
import com.wlgc.entity.RestBean;
import com.wlgc.entity.dto.UserPageQueryDTO;
import com.wlgc.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
@Slf4j
@PreAuthorize("hasAuthority('index')")
public class UserController {

    @Autowired
    private UserService userService;


    @GetMapping("/student/page")

    public RestBean<PageResult> page( UserPageQueryDTO userPageQueryDTO){
        userPageQueryDTO.setUid(BaseContext.getCurrentId());
        log.info("分类查询:{}",userPageQueryDTO);
        PageResult pageResult = userService.pageQuery(userPageQueryDTO);
        System.out.println(pageResult.getRecords());
        return RestBean.success(pageResult);
    }
}
